package com.lengxf.mybatis.mysql.transactionTest;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
@AllArgsConstructor
public class TransactionTestController {

    private final TransactionTestService transactionTestService;


    @GetMapping("t1")
    public String test() {
        try {
            transactionTestService.test1();
        } catch (Exception e) {
            //此处无论是否抛出异常  事务都会生效
//            throw new RuntimeException(e);
        } finally {
            System.out.println("finally...");
        }
        return "ok";
    }


}
